﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

// 敌机属性
public class EnemyPlane : MonoBehaviour {

	protected GameObject target;

	protected string type;//敌机类型
	protected float hp;//敌机hp
	protected float currHp;
	protected float defendPower;//防御力
	protected float defendHP;//防御罩血量
	protected float recoverHP;//恢复能力
	protected float speed;//飞行速度
	protected float resistanceLaser;//激光抗性
	protected float resistanceMissile;//导弹抗性
	protected float resistanceBullet;//实弹抗性
	protected int producePower;//造船技术力

	public static string Type_SmallEnemyPlane = "smallEnemyPlane";
	public static string Type_MiddleEnemyPlane = "middleEnemyPlane";
	public static string Type_BigEnemyPlane = "bigEnemyPlane";

	public bool isDeath;
	protected float distanceTarget;//与目标的距离
	protected float distanceWeaponAttack;//武器的攻击范围
	protected Transform startTrans;//飞机产生的位置
	protected Star star;//生产飞机的星球对象

	protected HPSlider hpSlider;

	// private string icon;//贴图
	// private string prefab_body;//战斗界面贴图
	// private string prefab_explosion;//爆炸动画

	/// <summary>
	/// Start is called on the frame when a script is enabled just before
	/// any of the Update methods is called the first time.
	/// </summary>

	public float Speed
	{
		set{
			speed = value;
		}
		get{
			return speed;
		}
	}



	public void SetTarget(GameObject target)
	{
		this.target = target;
	}

	

	public void setStar(Star star)
	{
		this.star = star;
	}

	public float GetHp()
	{
		return hp;
	}

	public void SetRecoverHp(float recoverHP)
	{
		this.recoverHP = recoverHP;
	}


	// 恢复生命
	public void RecoverHp()
	{
		if(currHp < hp)
		{
			float bufferHp = currHp + recoverHP;
			if(bufferHp < hp)
			{
				currHp = bufferHp;
			}
			else
			{
				currHp = hp;
			}
		}
	}

}
